package com.sphd.restaurantsystem.presenter;


import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.info.PushScaleInfo;
import com.sphd.restaurantsystem.model.SetPushModelImpl;
import com.sphd.restaurantsystem.view.SetPushView;

import java.util.List;


/**
 * Created by Hu on 2016/12/13
 */

public class SetPushPresenterImpl implements SetPushPresenter {
    SetPushModelImpl setPushModel;
    SetPushView setPushView;
    String ms=null;
    int type=-1;
    public SetPushPresenterImpl(SetPushView setPushView) {
        this.setPushView = setPushView;
        setPushModel = new SetPushModelImpl();
    }

    @Override
    public void addData(String url) {

    }

    public void addData(String url, String ms, int type) {
        this.ms=ms;
        this.type=type;
        setPushView.showLoading();
        setPushModel.sendUrl(url, this);
    }

    @Override
    public void sendError(VolleyError error) {
        setPushView.dissLoading();
    }

    @Override
    public void recRes(int res) {
        if (res==1){
            setPushView.recResOk(ms,type);
        }else {
            setPushView.recResFaile();
        }
         ms=null;
         type=-1;
        setPushView.dissLoading();
    }

    @Override
    public void getSetVal(String url) {
        setPushView.showLoading();
        setPushModel.getSetVal(url, this);
    }

    @Override
    public void recList(List<PushScaleInfo> pushScaleInfos) {
        setPushView.recList(pushScaleInfos);
        setPushView.dissLoading();
    }
}